DatePart

Definition:

DatePart(interval, date[, firstdayofweek[, firstweekofyear]])

 

Description:

Pick out a specified part from a date string.

 

Platforms:

All

 

Parameters:

interval - required

The type of time unit you want to pick out from the supplied date. Possible values are:

"d" - Day of month

"w" - Day of week

"y" - Day of year

"m" - Month

"yyyy" - Year

"h" - Hour

"n" - Minute

"s" - Second

"ww" - Week of year

"q" - Quarter (3 months)

 

date - required

String containing the date, date and time or time.

Supported formats for this parameter are the same as those supported by VBScript DateTime objects.

 

firstdayofweek - optional

Number specifying the first day of the week.

Possible values are:

0 - Use system settings (NLS API system setting)

1 - Sunday (default)

2 - Monday

3 - Tuesday

4 - Wednesday

5 - Thursday

6 - Friday

7 - Saturday

 

firstweekofyear - required

This parameter is ignored and can be omitted.

 

 

Returns:

String containing the specified part of the supplied date.

 

Notes:

If you specify a date without a time in the date parameter, the time will be assumed to be 00:00:00.

If you want to use the current date and time, you can use the Now Method to obtain this in a suitable format for use within this Method.